<?php
class Cash_record_model extends BZ_Model
{
    protected $table = 'cash_record';
    
    /**
     * 记录现金流
     * @param unknown $orderProfitItem
     * @param unknown $type
     */
    public function insertIntoCashRecord($order_id, $uid, $account, $type, $account_type=1, $product_type='line')
    {
        $data = array(
            'order_id'     => $order_id,
            'uid'          => $uid,
            'amount'       => $account,
            'level'        => $type,
            'account_type' => $account_type,
            'time'         => time(),
            'product_type' => $product_type
        );
        $this->db->insert($this->table, $data);
        return $this->db->insert_id();
    }
    
    /**
     * 批量插入分润记录
     * @param $orderProfitItem
     * @param $type
     * @return mixed
     */
    public function insertBatchCashRecord($orderProfitItem)
    {
        $data = array();
        foreach($orderProfitItem as $value){
            $data[] = array(
                'order_id'     => $value->order_id,
                'uid'          => $value->uid,
                'amount'       => $value->account,
                'account_type' => $value->account_type,
                'level'        => $value->type,
                'time'         => time(),
                'product_type' => 'tourism'
            );
        }
        return $this->db->insert_batch($this->table, $data);
    }
}